//
//  CSVStringTests.m
//  com.oos.kraken
//
//  Created by Pablo Gonzalez on 2/17/11.
//  Copyright 2011 11870.com. All rights reserved.
//


#import <SenTestingKit/SenTestingKit.h>
#import "../Utils/NSStringUtils.h"
#import "OosTestHelper.h"
#import "GDataHTTPFetcher.h"
#import "GDataServiceBase.h"


@interface CSVStringTests : OosTestHelper {
}

- (void) testInitiation;

- (void) testString: (NSString *) string;

@end

@implementation CSVStringTests

#pragma mark tests

- (void) testInitiation
{
	NSString *string = @"";
	string = [NSStringUtils addValue:@"one" toString: string];
	string = [NSStringUtils addValue:@"two" toString: string];
	STAssertNotNil(string, @"The string cannot be nil.");
	[self testString: string];
	
	string = @"one,two";
	STAssertNotNil(string, @"String from String is not generated");
	[self testString: string];
}

- (void) testString: (NSString *)string
{
	[self assertNotNil:string withName:@"CSVString"];
	STAssertTrue([[NSStringUtils valuesFromString:string] count] == 2, @"There must be two values");
	NSArray *values = [NSStringUtils valuesFromString: string];
	STAssertTrue([[values objectAtIndex: 0] isEqualToString: @"one"], @"From string, First value is not equal");
	STAssertTrue([[values objectAtIndex: 1] isEqualToString: @"two"], @"From string, Second is not equal");
	
	string = [NSStringUtils removeValue:@"two" fromString: string];
	STAssertTrue([[NSStringUtils valuesFromString: string] count] == 1, @"There must be only one value");
	
	string = @"";
	string = [NSStringUtils addValue:@"other" toString: string];
	STAssertTrue([[NSStringUtils valuesFromString: string] containsObject: @"other"], @"Insertion doesn't work");
	
	string = [NSStringUtils addValue:@"one more" toString: string];
	STAssertTrue([string isEqualToString: @"other,one more"], @"Not equal");
}



@end
